package com.liweiwei.role.controller;

import com.liweiwei.role.base.BaseController;
import com.liweiwei.role.bean.RoleBean;
import com.liweiwei.role.service.RoleService;
import com.liweiwei.role.service.serviceImpl.RoleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.List;

@WebServlet(name="RoleGetController",urlPatterns="/LWW/get")
public class RoleGetController extends BaseController{
        // 使用get请求查找页面
        // 调用服务

        private RoleService roleService=new RoleServiceImpl();

    @Override
    public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
        // 请求拿到url的method值
        String method = request.getParameter("method");
        if("findAllRole".equals(method)){
            findAllRole(request, response);
        }
    }

    private void findAllRole(ServletRequest request, ServletResponse response) {
       // String rs = request.getParameter("id");
      //  int id = Integer.parseInt(rs);
        // 调用service的方法
        List<RoleBean> roleBeans = roleService.finAllRole();
        boolean check=roleBeans!=null;
        printData(check,roleBeans,500, response);
    }
}

